import router from "./index";
import store from '../store'
export default function () {
  router.beforeEach(function (to, from, next) {
    // console.log(to)
    // console.log(from)
    // store.state.activeMenuItem = {
    //   name: to.name,
    //   label: '标准产品'
    // }
    store.state.urls = to.path;
    // console.log(store.state.activeMenuItem)
    // console.log(this)
    // this.$message.error('您无权限查看此页');
    if (sessionStorage.getItem('author_token')) { // 判断是否登录
      next()
    } else if (to.path === '/login') {
      next()
    } else if (to.path.indexOf("/admin") != -1) {
      sessionStorage.clear()
      next({
        path: '/login'
      })
    } else {
      sessionStorage.clear()
      next({
        path: '/login'
      })
    }
  });
}
